<template>
  <div class="dashboard-editor-container">
    <panel-group @handleSetLineChartData="handleSetLineChartData"/>
    <el-row style="background:#fff; margin-bottom:32px;">
      <china-map/>
    </el-row>
    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-wrapper">
          <line-chart :chart-data="lineChartData"/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-wrapper">
          <bar-chart/>
        </div>
      </el-col>  
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-wrapper">
          <raddar-chart/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-wrapper">
          <pie-chart/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import GithubCorner from '@/components/GithubCorner'
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
import RaddarChart from './components/RaddarChart'
import PieChart from './components/PieChart'
import BarChart from './components/BarChart'
import ChinaMap from './components/ChinaMap'

const lineChartData = {
  totalDevice: {
    curData: [41021, 41120, 41161, 42134, 42605, 42699, 42779],
    preData: [35120, 36082, 37091, 38154, 39162, 39940, 40021]
  },
  online: {
    curData: [19200, 18192, 19120, 18144, 18160, 10130, 11140],
    preData: [16180, 19160, 16151, 19106, 14145, 12150, 13130]
  },
  offline: {
    curData: [16180, 15100, 17121, 15104, 17105, 20090, 19100],
    preData: [13120, 17590, 18100, 13138, 15142, 10130, 14130]
  },
  time: {
    curData: [100130, 103140, 110141, 100142, 121145, 90150, 100160],
    preData: [100120, 103282, 100091, 100154, 90162, 100140, 120130]
  }
}

export default {
  name: 'DashboardAdmin',
  components: {
    GithubCorner,
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart,
    ChinaMap
  },
  data() {
    return {
      lineChartData: lineChartData.totalDevice
    }
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}
</style>
